package com.itheima.health.dao;


import com.itheima.health.vo.HotSetmealVo;
import com.itheima.health.vo.MemberOrderVo;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;

import com.itheima.health.pojo.Order;


@Mapper
public interface OrderDao {
    Integer selectOrderCount(LocalDate start, LocalDate stop);

    Integer selectOrderCountYes(LocalDate start, LocalDate stop, String status);

    Integer selectSetmealCountByOrder(Integer id);

    Integer selectOrderCountAll( LocalDate endDay);

    /**
     * 根据订单表 会员id 预约日期 套餐id 查询套餐预约的数量
     */
    long selectOrder(@Param("memberId") Integer memberId, @Param("orderDate") String Date , @Param("setmealId") Integer setmealId);

    /**
     * 新增预约
     */
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into t_order(member_id, orderDate, orderType, orderStatus, setmeal_id) VALUES (#{memberId}, #{formatOrderDate}, #{orderType}, #{orderStatus}, #{setmealId})")
    void insert(Order order);

    /**
     * 根据预约id查询
     */
    Order selectById(Integer id);

    /**
     * 根据id查询订单详情
     * @param id
     * @return
     */
    @Select("select o.orderDate,o.orderType,m.name as member,s.name as setmeal from t_order o,t_member m,t_setmeal s where o.id = #{id} and o.member_id = m.id and o.setmeal_id = s.id")

    MemberOrderVo selectMemberOrderById(Integer id);

    /**
     * 15_统计分析-运营统计
     *
     * @return
     */
    List<HotSetmealVo> findHotSetmeal();

    @Select("select count(*) from t_order")
    int selectAllCount();

    int selectCountByName(String name);
}
